﻿Public Class GlyphCanvas
    Inherits InkCanvas

    Shared Sub New()
        StrokesProperty.OverrideMetadata(GetType(GlyphCanvas), New FrameworkPropertyMetadata(StrokesProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.AffectsMeasure))
    End Sub

    Public Sub New()
        AddHandler RequestBringIntoView, Sub(sender, e) e.Handled = True
    End Sub



    Public Shared ReadOnly GlyphWidthProperty As DependencyProperty = _
        DependencyProperty.Register( _
            "GlyphWidth", GetType(Double), GetType(GlyphCanvas), _
            New FrameworkPropertyMetadata(200.0#, FrameworkPropertyMetadataOptions.AffectsMeasure))

    Public Property GlyphWidth As Double
        Get
            Return CType(GetValue(GlyphWidthProperty), Double)
        End Get
        Set(ByVal value As Double)
            SetValue(GlyphWidthProperty, value)
        End Set
    End Property




    Protected Overrides Function MeasureOverride(s As Size) As Size
        MyBase.MeasureOverride(s)
        Dim width = GlyphMetrics.BorderOverflow * 2 + GlyphWidth
        Dim height = GlyphMetrics.Height + GlyphMetrics.BorderOverflow * 2
        Return New Size(width, height)
    End Function

    Protected Overrides Function ArrangeOverride(arrangeSize As Size) As Size
        MyBase.ArrangeOverride(arrangeSize)
        Return DesiredSize
    End Function

End Class
